#include <iostream>
#include <list>
using namespace std;

// Character
struct Character {
	static int ID;
	int HP;
	int x;
	int y;
	Character(int _HP, int _x, int _y){
		ID++;
		HP = _HP;
		x = _x;
		y = _y;
	}
};

int Character::ID = 0;

void main()
{
	list<Character> npcList;

	// list 앞쪽에 데이터 추가
	Character ch1(100, 50, 50);
	npcList.push_front(ch1);

	Character ch2(200, 100, 50);
	npcList.push_front(ch2);

	// list 뒤쪽에 데이터 추가
	Character ch3(50, 80, 50);
	npcList.push_back(ch3);

	Character ch4(150, 200, 300);
	npcList.push_back(ch4);

	// 반복자 선언 (순방향)
	list<Character>::iterator iter;

	// HP 출력 (순방향)
	cout << "순방향 출력 "  << endl;
	for(iter = npcList.begin(); iter != npcList.end(); iter++)
		cout << "HP : " << iter->HP << endl;

	// 마지막 캐릭터 삭제
	npcList.pop_back();
	
	// HP 출력 (역방향)
	cout << "\n¸마지막 데이터 삭제 후 역방향 출력 " << endl;
	list<Character>::reverse_iterator rIter;
	for(rIter = npcList.rbegin(); rIter != npcList.rend(); rIter++)
		cout << "HP : " << rIter->HP << endl;
}